package com.lin.carbon.controller;

import com.lin.carbon.dto.RegisterRequest;
import com.lin.carbon.service.SysAccountRegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/auth")
public class SysAccountController {

    @Autowired
    private SysAccountRegisterService sysAccountService;

    @PostMapping("/register")
    public String register(@Validated @RequestBody RegisterRequest request) {
        System.out.println("成功进入注册接口");
        boolean success = sysAccountService.register(request);
        if (success) {
            return "注册成功";
        } else {
            return "注册失败";
        }
    }

    @PostMapping("/checkName") // 修改路径和方法名
    public boolean check(@Validated @RequestBody RegisterRequest request) {
        return sysAccountService.check(request);
    }
}